#ifndef BLOCKFILEMANAGER_H_
#define BLOCKFILEMANAGER_H_

#include <fstream>   // Biblioteca para el manejo de ficheros
#include <iostream> // Biblioteca para la entrada-salida estándar
#include <cstdlib>
#include <string>
#include <vector>
//#include "VarFileManager.h"
using namespace std;

enum OpenMode
{
	Read,
	Write,
	Append
};


class BlockFileManager {

private:
    int blockSize;
	void openFile(OpenMode mode);
	void addFreeBlock(int blockNumber);
	void updateCantFreeBlocks();
	string filePath;
	string freeBlocksFilePath;
	fstream blockFile;
	fstream freeBlocksFile;//Archivo de registros de longitud fija de 2 Bytes
	int cantFreeBlocks;
public:

	BlockFileManager(int blockSize, string path);
	int writeNewBlock(char* buffer);
	char* readBlock(int blockNumber);
	void deleteBlock(int blockNumber);
	void updateBlock(char* buffer,int blockNumber);
	bool isFreeBlock(int blockNumber);
	int getFreeBlocks();
	vector<int> * getVecFreeBlocks();
	int getNumberOfBlocks();
	int getBlockSize();
	virtual ~BlockFileManager();
};

#endif /* BLOCKFILEMANAGER_H_ */
